package com.jdbc.conn;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author wzm
 * @create 2023-02-23 10:40
 */
//通过德鲁伊数据库连接池获取连接信息
public class Conn03 {
    public static void main(String[] args) throws Exception {
        //加载了配置文件
        Properties properties = new Properties();
        properties.load(
                Conn03.class
                        .getClassLoader()
                        .getResourceAsStream("druid.properties"));


        //DataSource接口有jdk指定 实现了由德鲁伊实现
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);

        Connection conn = dataSource.getConnection();
        System.out.println("conn = " + conn);
        if(conn != null){
            System.out.println("恭喜打开连接成功");
        }

    }



}
